package cn.wu.reggie.mapper;

import cn.wu.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

public interface UserMapper {

    @Select("select * from user where phone = #{phone}")
    User findByPhone(String phone);

    @Insert("insert into user(phone,status) values(#{phone},#{status})")
    @SelectKey(statement = "select last_insert_id()",before = false,keyColumn = "id",keyProperty = "id",resultType = Long.class)
    void save(User user);

    @Select("select * from user where id = #{id}")
    User findById(Long userId);
}
